package com.interview.strategy;


import com.interview.domain.OrderItem;

import java.math.BigDecimal;
import java.math.RoundingMode;

public abstract class PricingStrategy {
    public abstract OrderItem calculateCost(BigDecimal price, BigDecimal quantity, String title);//单价 数量

    public OrderItem costTotal(String price,String quantity,String name){
        BigDecimal priceNum = new BigDecimal(price).setScale(2, RoundingMode.UP);
        BigDecimal quantityNum = new BigDecimal(quantity).setScale(2, RoundingMode.UP);
        BigDecimal zero = new BigDecimal("0");
        assert zero.compareTo(priceNum)<0:"商品价格需大于0";
        assert zero.compareTo(quantityNum)<=0:"商品数量不能小于0";
        return calculateCost(priceNum, quantityNum,name);
    }
}

